//
//  ViewController.m
//  28-AutoLayoutAnimation
//
//  Created by 曹曹 on 16/8/22.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *centerY;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutLeft150;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutLeft20;

@end

@implementation ViewController

- (IBAction)buttonClicked:(id)sender {
#if 0
    // 改变centerY的constant
    self.centerY.constant = -50;
    // 执行动画效果
    [UIView animateWithDuration:2 animations:^{
        // 必须调用 layoutIfNeeded
        [self.view layoutIfNeeded];
    }];
#endif
    // 约束的优先级, 改变时需要注意, 不能为1000, 否则程序会崩溃
    // 同一约束优先级高的会被执行, 优先级低的会被忽略
    self.layoutLeft20.priority = 751;
    self.layoutLeft150.priority = 750;
    [UIView animateWithDuration:2 animations:^{
        [self.view layoutIfNeeded];
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
